package com.itheima.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckItemGroupMapper {
    /**
     * 添加检查组和检查项的关联关系
     * @param id
     * @param itemId
     */
    @Insert("insert into t_checkgroup_checkitem (checkgroup_id, checkitem_id) values(#{id},#{itemId})")
    void insertCheckGroupAndCheckItem(Integer id, Integer itemId);

    /**
     * 根据检查组id删除检查项和检查组的关联关系
     * @param id
     */
    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{id}")
    void deleteByCheckGroupId(Integer id);

    /**
     * 根据检查组id查询检查项id
     * @param id
     * @return
     */
    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id}")
    List<Integer> getCheckItemIdsByCheckGroupId(Integer id);
}
